#include <cstdio>
#include <unistd.h>
#include <syscall.h>
#include <iostream>

void TaskInSubProcess()
{
    pid_t pid = fork();
    if (pid == -1)
    {
        std::cerr << "Failed to fork process\n";
        return;
    }

    if (pid == 0)
    {
        // 子进程
        printf("I am in sub process[%d]..\n", ::syscall(SYS_getpid));
        // 子进程
        char cmd[512]{};
        snprintf(cmd, sizeof(cmd), "python3 filt.py 20230516.log [6019 6019.txt");
        system(cmd);
        printf("Script executed..\n");
        exit(0);
    }
}

int main(int argc, char *argv[])
{
    TaskInSubProcess();

    printf("I am in main process[%d]..\n", ::syscall(SYS_getpid));

    // usleep(50000);

    printf("main hello \n");

    // getchar();
    return 0;
}